package com.sun.mychat.controller;

import com.sun.mychat.pojo.User;
import com.sun.mychat.service.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/zhuce")
    public int zhuce(@RequestBody User user) {
        return userService.zhuce(user);
    }

    @PostMapping("/zh")
    public int zhanghao(@RequestBody User user) {
        User user1 = userService.zhanghao(user.getUid());
        if (user1 == null) {
            return 0;
        } else {
            return 1;
        }
    }

    @PostMapping("/sjh")
    public int sjh(@RequestBody User user) {
        User user1 = userService.sjh(user.getTel());
        if (user1 == null) {
            return 0;
        } else {
            return 1;
        }
    }
}
